package org.trinity.netdisk.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class MailUtil {
    @Autowired
    JavaMailSender sender;

    @Autowired
    private MailProperties mailProperties;

    public void sendTo(String mail, String text){
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setTo(mail);
        simpleMailMessage.setSubject("凤梨网盘验证码");
        simpleMailMessage.setFrom(mailProperties.getUsername());
        simpleMailMessage.setText(text);
        sender.send(simpleMailMessage);
    }
}
